#!/bin/sh
set -e

PYCENTRAL=/usr/bin/pycentral

if [ "$1" = upgrade ]
then
	if dpkg --compare-versions "$2" lt 0.9.3-3 ; then
		if [ -x $PYCENTRAL ]; then
			# explicitly remove old python-central files
			pycentral pkgremove shogun-python-modular
		fi
	fi  
	if dpkg --compare-versions "$2" lt 0.10.0-1 ; then
		# be really sure also removing left-over files and dirs
		# we do outside the previous 'if' since first pysupport
		# release was already distributed
		for pydir in site-packages dist-packages; do
			for pyversion in 2.4 2.5 2.6; do
				if [ -d /usr/lib/python$pyversion/$pydir/shogun/ ]; then
					rm -f /usr/lib/python$pyversion/$pydir/shogun/*
					rmdir --ignore-fail-on-non-empty /usr/lib/python$pyversion/$pydir/shogun/
				fi
			done
		done
	fi
fi

#DEBHELPER#
